package org.daidai.abstrusewriting.homepage.top.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import org.daidai.abstrusewriting.fragments.BaseFragment;

import java.util.List;

/**
 * Created by liuch on 2016/11/1.
 */

public class FragmentAdapter extends FragmentStatePagerAdapter {

    private List<BaseFragment> mFragments;

    public FragmentAdapter(FragmentManager fm , List<BaseFragment> fragments) {
        super(fm);
        mFragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment ret = null;
        if (mFragments != null) {
            ret = mFragments.get(position);
        }
        return ret;
    }

    @Override
    public int getCount() {
        int ret = 0;
        if (mFragments != null) {
            ret = mFragments.size();
        }
        return ret;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mFragments.get(position).getFragmentTitle();
    }
}
